'use strict'
const path = require('path')

module.exports = {
  configureWebpack: {
    resolve: {
      alias: {
        'src': path.resolve(__dirname, './src'),
        'api': path.resolve(__dirname, './src/api'),
        'store': path.resolve(__dirname, './src/store'),
        'page': path.resolve(__dirname, './src/components/page'),
        'common': path.resolve(__dirname, './src/components/common')
      },
    },
  },

  publicPath: '/',
  outputDir: 'dist',
  assetsDir: 'public',
  productionSourceMap: false,

  devServer: {
    port: 9999,
    proxy: {
      '/api':{
        target:'http://127.0.0.1:9000',     //后端网关地址
        // target: 'https://www.fastmock.site/mock/f9393a77496cb47c28c900669f52c804/test',     // fast mock地址
        changeOrigin:true,
        pathRewrite:{
          '^/api':''                        //拦截axios请求路径,并将`/api`替换为 网关地址进行请求
        }
      },
      '/lib':{
        target:'http://127.0.0.1:8080',     //后端网关地址
        // target: 'https://www.fastmock.site/mock/f9393a77496cb47c28c900669f52c804/test',     // fast mock地址
        changeOrigin:true,
        pathRewrite:{
          '^/':''                        //拦截axios请求路径,并将`/api`替换为 网关地址进行请求
        }
      }
    }
  },

  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'sass',
      patterns: [
        path.resolve(__dirname, './src/assets/scss/*.scss')      //你的.scss文件所在目录
      ]
    }
  },

  chainWebpack: config => {
    config.module
      .rule('svg-sprite')
      .use('svgo-loader')
      .loader('svgo-loader');
  }
}
